<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.control.ScoreControl"%>
<%@ page import="com.control.UserControl"%>
<%@ page import="com.control.CourseControl"%>
<%@ page import="com.model.Score"%>
<%@ page import="com.model.User"%>
<%@ page import="com.model.Course"%>
<%@ page import="com.util.PageResultSet"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>成绩显示</title>
	</head>
	<body>
		<%
			request.setCharacterEncoding("UTF-8");
			String ToolBar = "";
	    	int curPage = 1;
			int course_id = 0;
			String course_name = "";
			UserControl uc = new UserControl();
			CourseControl cc = new CourseControl();
			if(request.getParameter("course_name")!= null) {
				course_name = request.getParameter("course_name"); 
				course_id = cc.getCourseID(course_name);
			}
		%>
		<table width="98%" border="0" align="center">
			<tr>
				<td></td>
			</tr>
			<tr>
				<td></td>
			</tr>
			<tr>
				<td>
					<fieldset>
						<legend> 
							成绩查询 
						</legend>
						<form action="search_course.jsp" name="form1" method="post"><br><table width="60%" border="0" align="center" cellspacing="0"
								cellpadding="0">
								<tr align="center">
									<td align="center"> 
										 课程名 
								        <input name="course_name" type="text" size="5" <%if(!course_name.equals(""))%> value="<%=course_name %>"/>&nbsp; 
									   	<input type="submit" value="查询" />
									</td>
								</tr>
								<tr>
									<td>
										<table border="1" width="99%" align="center" cellpadding="0"
											cellspacing="1" class="resultTable">
											<tr>
												<td width="2%" height="25" align="center" bgcolor="#D9F0FF">  
													学号<br></td>
												<td width="4%" height="25" align="center" bgcolor="#D9F0FF">  
												           姓名<br></td>
												<td width="5%" height="25" align="center" bgcolor="#D9F0FF">  
												          成绩<br></td>
								</tr>
								
								<%
									ScoreControl sc = new ScoreControl();
									ArrayList<Score> list = new ArrayList<Score>();
									list = sc.getAllStudentScore(course_id);
									if(request.getParameter("cur_page")!= null) {
										curPage = Integer.parseInt(request.getParameter("cur_page")); 
									}
									PageResultSet p = new PageResultSet(list,curPage);
									ArrayList<Score> nowlist = new ArrayList<Score>();
									nowlist = (ArrayList<Score>)p.getData();
									for(int i=0; i<nowlist.size(); i++) {
										Score score = nowlist.get(i);
										int student_id = score.getStudent_id();
										User user = uc.getUser(student_id);
										if(!cc.Lock(course_id)){
								%>
									<tr>
        								<td height="25" align="center"><%=user.getUsername()%></td>
 										<td height="25" align="center"><%=user.getName()%></td>
 										<td height="25" align="center">未录入</td>
 									</tr>
 									<%} else{%>
								 	<tr>
        								<td height="25" align="center"><%=user.getUsername()%></td>
 										<td height="25" align="center"><%=user.getName()%></td>
 										<td height="25" align="center"><%=score.getPoint()%></td>
 									</tr>
   									<%}}
   										
										String fileName = "search_course.jsp";
										ToolBar = p.getToolBar(fileName);
									%>
							</table>
							<%=ToolBar %>
							</td>
							</tr>
							</table><br></form>
					</fieldset>
				</td>
			</tr>
		</table>
	</body>
</html>
